package com.silence.gankio.adapter

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import com.silence.gankio.fragment.GankAndroidFragment
import com.silence.gankio.fragment.GankWealFragment
import com.silence.gankio.fragment.IsoyuVideoFragment

class MainFragmentAdapter : FragmentPagerAdapter {


    private val titles = mutableListOf<String>()

    constructor(fm: FragmentManager) : super(fm) {
        titles.add("Android")
        titles.add("福利")
        titles.add("Video")
    }

    override fun getItem(p0: Int): Fragment {
        return when (p0) {
            0 -> {
                GankAndroidFragment.newInstance()
            }
            1 -> {
                GankWealFragment.newInstance()
            }
            2 -> {
                IsoyuVideoFragment.newInstance()
            }
            else -> {
                GankAndroidFragment.newInstance()
            }
        }
    }

    override fun getCount() = 3

    override fun getPageTitle(position: Int): CharSequence? {
        return titles[position]
    }
}